{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}
<div class="p-3">
    <form class="layui-form gg-form-bar border-x border-t" lay-filter="barsearchform">

        <!--<div class="layui-input-inline" style="width:240px;">-->
        <!--<input type="text" name="keywords" placeholder="输入公司名称" class="layui-input" autocomplete="off"/>-->
        <!--</div>-->
        <!--<div class="layui-input-inline" style="width:150px;">-->
        <!--<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform"><i-->
        <!--class="layui-icon layui-icon-search mr-1"></i>搜索-->
        <!--</button>-->
        <!--<button type="reset" class="layui-btn layui-btn-reset" lay-filter="reset">清空</button>-->
        <!--</div>-->
    </form>
    <h3>公司总体年统计报表</h3>
    <table class="layui-hide" id="test" lay-filter="test"></table>
</div>

<script type="text/html" id="toolbarDemo">

</script>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
    const moduleInit = ['tool'];
    // {
    //     field: 'check_status', title: '状态', align: 'center', width: 200, templet: function (d) {
    //     var html = '<span class="layui-btn layui-btn-xs layui-bg-' + d.check_status + '">' + d.status_name + '</span>';
    //     return html;
    // }
    // },
    function gouguInit() {
        var table = layui.table, tool = layui.tool, form = layui.form;
        layui.pageTable = table.render({
            elem: '#test',
            title: '员工日统计',
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', {title: '导出EXCEL', layEvent: 'LAYTABLE_EXCEL', icon: 'layui-icon-export'}],
            url: "/finance/report/company_year_index", //数据接口
            cellMinWidth: 80,
            page: true, //开启分页
            limit: 15,
            cols: [
                [ //表头
                    {
                        field: 'id',
                        title: '编号',
                        align: 'center',
                        width:80,
                        templet: function (d) {
                            return d.LAY_INDEX+1
                        }
                    },{
                    field: 'day',
                    title: '年份',
                    align: 'center',
                },{
                    field: 'total_incomes',
                    title: '总收款金额',
                    align: 'center',
                }, {
                    field: 'total_payments',
                    title: '总付款金额',
                    align: 'center',
                },{
                    field: 'lirun',
                    title: '利润',
                    align: 'center',
                },{
                    field: 'gxl',
                    title: '贡献率',
                    align: 'center',
                }
                ]
            ]
        });

        //表头工具栏事件
        table.on('toolbar(test)', function (obj) {

            if (obj.event === 'LAYTABLE_EXCEL') {
                var formSelect = form.val('barsearchform');
                formSelect.limit = 99999;
                $.ajax({
                    url: '/finance/report/company_year_index',
                    data: formSelect,
                    success: function (res) {
                        table.exportFile('test', res.data, 'xls');
                    }
                });
                return;
            }
        });


        //监听搜索提交
        form.on('submit(webform)', function (data) {
            layui.pageTable.reload({
                where: {
                    keywords: data.field.keywords,
                    cate_id: data.field.cate_id,
                    type: data.field.type,
                    check_status: data.field.check_status
                },
                page: {
                    curr: 1
                }
            });
            return false;
        });
    }
</script>
{/block}
<!-- /脚本 -->
